package com.blacksheep.mtm.dto;

import com.blacksheep.mtm.pojo.common.ZTreeNode;
import com.blacksheep.mtm.pojo.manager.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



/**
 * @author   Z
 * @date 2017/8/25
 */
public class DtoUtil{

    private final static Logger log= LoggerFactory.getLogger(DtoUtil.class);





    public static ZTreeNode TbPanel2ZTreeNode(TbPanel tbPanel){

        ZTreeNode zTreeNode =new ZTreeNode();

        zTreeNode.setId(tbPanel.getId());
        zTreeNode.setIsParent(false);
        zTreeNode.setpId(0);
        zTreeNode.setName(tbPanel.getName());
        zTreeNode.setSortOrder(tbPanel.getSortOrder());
        zTreeNode.setStatus(tbPanel.getStatus());
        zTreeNode.setRemark(tbPanel.getRemark());
        zTreeNode.setLimitNum(tbPanel.getLimitNum());
        zTreeNode.setType(tbPanel.getType());

        return zTreeNode;
    }



    public static TbMember MemberDto2Member(MemberDto dto){
        TbMember member = new TbMember();
        if (dto.getId() !=null){
            member.setId((long)dto.getId());
        }
        member.setUsername(dto.getUsername());
        member.setRealname(dto.getRealname());
        member.setPhone(dto.getPhone());
        member.setIdcode(dto.getIdcode());
        member.setRole(dto.getRole());
        if (!StringUtils.isBlank(dto.getSupplierId())){
            member.setSupplierId(dto.getSupplierId());
        }
        return member;
    }




}
